import url from 'url';
import { createRunner } from '@puppeteer/replay';

export async function run(extension) {
    const runner = await createRunner(extension);

    await runner.runBeforeAllSteps();

    await runner.runStep({
        type: 'setViewport',
        width: 1065,
        height: 739,
        deviceScaleFactor: 1,
        isMobile: false,
        hasTouch: false,
        isLandscape: false
    });
    await runner.runStep({
        type: 'navigate',
        url: 'https://eic-oauth.eiceducation.com.cn/login?logout',
        assertedEvents: [
            {
                type: 'navigation',
                url: 'https://eic-oauth.eiceducation.com.cn/login?logout',
                title: '统一认证平台'
            }
        ]
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'aria/登 录'
            ],
            [
                'div.username-login > button'
            ],
            [
                'xpath//html/body/div/div[2]/div[2]/form/div[1]/button'
            ],
            [
                'pierce/div.username-login > button'
            ]
        ],
        offsetY: 13.15625,
        offsetX: 100.40625,
        assertedEvents: [
            {
                type: 'navigation',
                url: 'https://emsp.eiceducation.com.cn/admin/tokenLogin?auth_code=394541&email=mumulin@eiceducation.com.cn&code=&loginType=passwordLogin&phone_number=&captchaId=&username=mumulin',
                title: ''
            }
        ]
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'div:nth-of-type(8) div.flex1'
            ],
            [
                'xpath///*[@id="app"]/div/div[1]/div[1]/div/div[3]/div[1]/div[8]/a/div[2]'
            ],
            [
                'pierce/div:nth-of-type(8) div.flex1'
            ],
            [
                'text/系统工具'
            ]
        ],
        offsetY: 7.609375,
        offsetX: 113
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'div:nth-of-type(8) > div > div > div:nth-of-type(1) div.flex1'
            ],
            [
                'xpath///*[@id="app"]/div/div[1]/div[1]/div/div[3]/div[1]/div[8]/div/div/div[1]/a/div[2]'
            ],
            [
                'pierce/div:nth-of-type(8) > div > div > div:nth-of-type(1) div.flex1'
            ],
            [
                'text/工作移交'
            ]
        ],
        offsetY: 16.609375,
        offsetX: 76
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'div.tab-page > ul > li:nth-of-type(3)'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/ul/li[3]'
            ],
            [
                'pierce/div.tab-page > ul > li:nth-of-type(3)'
            ]
        ],
        offsetY: 18,
        offsetX: 34
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'div.tab-page > ul'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/ul'
            ],
            [
                'pierce/div.tab-page > ul'
            ],
            [
                'text/规划服务新高考合同新产品服务定校书审核文书服务APS服务录取服务录取外联签证服务签证外联后期服务服务文档审核离境信息客诉满意度'
            ]
        ],
        offsetY: 30,
        offsetX: 467
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'li:nth-of-type(6)'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/ul/li[6]'
            ],
            [
                'pierce/li:nth-of-type(6)'
            ],
            [
                'text/APS服务'
            ]
        ],
        offsetY: 23,
        offsetX: 24
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'li:nth-of-type(7)'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/ul/li[7]'
            ],
            [
                'pierce/li:nth-of-type(7)'
            ]
        ],
        offsetY: 26,
        offsetX: 21.15625
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'aria/搜索'
            ],
            [
                'div.flex1 > button.btn-primary'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/div[2]/div/form/div/div[2]/div[2]/button[1]'
            ],
            [
                'pierce/div.flex1 > button.btn-primary'
            ],
            [
                'text/搜索'
            ]
        ],
        offsetY: 17,
        offsetX: 23
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'div:nth-of-type(11) > div > div > div > div input'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/div[2]/div/form/div/div[1]/div[11]/div/div/div/div/label/input'
            ],
            [
                'pierce/div:nth-of-type(11) > div > div > div > div input'
            ]
        ],
        offsetY: 14,
        offsetX: 91
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'div.item_0 > div'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/div[2]/div/form/div/div[1]/div[11]/div/div/div/div[2]/div[2]/div'
            ],
            [
                'pierce/div.item_0 > div'
            ],
            [
                'text/amandazhang（amandazhang）'
            ]
        ],
        offsetY: 19,
        offsetX: 59
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'aria/搜索'
            ],
            [
                'div.flex1 > button.btn-primary'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/div[2]/div/form/div/div[2]/div[2]/button[1]'
            ],
            [
                'pierce/div.flex1 > button.btn-primary'
            ],
            [
                'text/搜索'
            ]
        ],
        offsetY: 26,
        offsetX: 34
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'div.selectUser div.col-sm-6 > div > div > div input'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/div[1]/form/div/div[2]/div/div/div/label/input'
            ],
            [
                'pierce/div.selectUser div.col-sm-6 > div > div > div input'
            ]
        ],
        offsetY: 13,
        offsetX: 135
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'div.item_0 > div'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/div[1]/form/div/div[2]/div/div/div[2]/div[2]/div'
            ],
            [
                'pierce/div.item_0 > div'
            ],
            [
                'text/amandazhang（amandazhang）'
            ]
        ],
        offsetY: 15,
        offsetX: 117
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'aria/搜索'
            ],
            [
                'div.flex1 > button.btn-primary'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/div[2]/div/form/div/div[2]/div[2]/button[1]'
            ],
            [
                'pierce/div.flex1 > button.btn-primary'
            ],
            [
                'text/搜索'
            ]
        ],
        offsetY: 20,
        offsetX: 24
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'form div:nth-of-type(11) i'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/div[2]/div/form/div/div[1]/div[11]/div/div/div/div/label/i'
            ],
            [
                'pierce/form div:nth-of-type(11) i'
            ]
        ],
        offsetY: 13,
        offsetX: 20
    });
    await runner.runStep({
        type: 'click',
        target: 'main',
        selectors: [
            [
                'aria/搜索'
            ],
            [
                'div.flex1 > button.btn-primary'
            ],
            [
                'xpath///*[@id="pageScrollBox"]/div[1]/div[2]/div/form/div/div[2]/div[2]/button[1]'
            ],
            [
                'pierce/div.flex1 > button.btn-primary'
            ],
            [
                'text/搜索'
            ]
        ],
        offsetY: 15,
        offsetX: 26
    });

    await runner.runAfterAllSteps();
}

if (process && import.meta.url === url.pathToFileURL(process.argv[1]).href) {
    run()
}
